<template>
    <view class="abc">
        <!-- <button type="default"  @click="setKey">set</button> -->
        <!-- <view >
            经度：{{longitude}}
            纬度：{{latitude}}
        </view> -->
        <map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :scale="scale" :markers="markers"></map>
    </view>
</template>
<script>
    export default {
        data(){
            return{
                longitude:"",
                latitude:"",
                scale:8,
                markers:[],
            }
        },
        onShow() {
            var that =this
            uni.getLocation({
                type: 'wgs84',
                success: function (res) {
                    console.log('当前位置的经度：' + res.longitude,res);
                    console.log('当前位置的纬度：' + res.latitude);
                    that.latitude=res.latitude
                    that.longitude=res.longitude
                    let arr =[
                        {
                            id:0,
                            longitude:res.longitude,
                            latitude:res.latitude,
                            name:'res.address'
                        }
                    ]
                    let markers = []
                    for (var i=0;i<arr.length;i++){
                        markers=markers.concat({ 
                            id:arr[i].id,
                            latitude: arr[i].latitude,//纬度
                            longitude: arr[i].longitude,//经度
                            callout:{//自定义标记点上方的气泡窗口 点击有效
                               content:arr[i].name,//文本
                               color:'#ffffff',//文字颜色
                               fontSize:10,//文本大小
                               borderRadius:2,//边框圆角
                               bgColor:'#00c16f',//背景颜色
                               display:'ALWAYS',//常显
                            },
                        })
                    }
                    that.markers=markers
                    console.log(that.markers)
                }
            })
			// https://restapi.amap.com/v3/geocode/regeo?output=xml&location=this.longitude,this.latitude&key=09c4ee4eb0c7020e3a55305424b3401b&radius=1000&extensions=all
            
        },
		methods:{
			// setKey(){}
		}
    }
</script>